

#!/bin/bash


# \033[1;31m 表示设置粗体、高亮的红色文本。
# \033[显示方式;前景色;背景色m
RED="\E[1;31m"
GREEN="\E[1;32m"
END="\E[0m"


echo -e "$GREEN------------------Host systeminfo-------------------$END"
echo -e "HOSTNAME:       $RED`hostname`$END"
echo -e "IPADDR:         $RED` ifconfig ens160 | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -n1`$END"
echo -e "OSVERSION:      $RED`uname -r`$END"
echo -e "KERNEL:         $RED`uname -r`$END"
# 将连续的空格挤压为一个空格：tr -s ' '
echo -e "CPU:             $RED`lscpu | grep 'Model name' | tr -s ' ' | cut -d : -f2| awk '{print}' | awk 'NR==1'`$END"
echo -e "MEMORY:          $RED`free -h | grep Mem| tr -s ' ' : | cut -d : -f2 | awk 'NR==1'`$END"
echo -e "DISK:            $RED`lsblk | grep '^nvme' | tr -s ' '| cut -d " " -f4| awk 'NR==1'`$END"
echo -e "$GREEN------------------Host systeminfo-------------------$END"